use ../Data/Clean/cleaned_recruiter_data.dta, clear
	* comapring white to white since we could not find enough black candidates. 
	keep if candidateiswhite==1
	gen gender_male = screenerismale
	gen race_white= screeneriswhite

	gen hm_female=hiringmanagerismale==0
	gen hm_black=hiringmanageriswhite==0
	gen hm_elite=hiringmanagereliteschool
	gen hm_empty=hiringmanagerisempty
	gen p_acceptinterview = pacceptinterview
	gen p_passinterview = ppassinterview
	gen p_acceptoffer = pacceptjoboffer
	
	keep screenerid hm_female hm_black hm_elite hm_empty p_acceptinterview p_passinterview p_acceptoffer gender_male race_white
	tostring(screenerid), replace
	gen recruiter_response=1

tempfile main
save "`main'"


use "../Data/Clean/clean_accuracy_managers.dta", clear
	* comapring white to white since we could not find enough black candidates. 
	keep if race_white==1
	drop if missing(p_acceptoffer )
	drop if missing(p_acceptinterview )
	rename responseid screenerid
	gen recruiter_response=0
	gen candidate_female=gender_female
	
append using "`main'"

foreach var in hm_female hm_black hm_elite hm_empty {
	gen rr_`var'=recruiter_response* `var'
}



egen race_genderid=group(gender_male race_white)
foreach var in educ_unselective educ_belavgselective educ_aboavgselective educ_elite firm_small firm_medium firm_large {
	replace `var'=0 if missing(`var')
}
gen evaluator_fes=race_genderid if recruiter_response==1
egen screener_numid=group(screenerid)
replace evaluator_fes=screener_numid if recruiter_response==0


global controls "gender_male race_white educ_unselective educ_belavgselective educ_aboavgselective firm_small firm_large"

************************************************************
****** Table C.1: ACCURACY OF CANDIDATE EVALUATIONS        *
************************************************************


reg p_acceptinterview hm_female hm_black hm_elite hm_empty recruiter_response rr_* $controls, r cluster(screenerid)
	test rr_hm_female=rr_hm_black=rr_hm_elite ==0
	estadd scalar pvalue=`r(p)'
	eststo one

reg p_passinterview hm_female hm_black hm_elite hm_empty recruiter_response rr_* $controls, r cluster(screenerid)
	test rr_hm_female=rr_hm_black=rr_hm_elite ==0
	estadd scalar pvalue=`r(p)'
	eststo two

reg p_acceptoffer hm_female hm_black hm_elite hm_empty recruiter_response rr_* $controls, r cluster(screenerid)
	test rr_hm_female=rr_hm_black=rr_hm_elite ==0
	estadd scalar pvalue=`r(p)'
	eststo three


	
label var hm_female "Female Hiring Manager"
label var hm_black "Black Hiring Manager "
label var hm_elite "Elite School Hiring Manager "
label var hm_empty "Empty Hiring Manager "
label var rr_hm_female "Recruiter Eval$\times$ Female Hiring Manager "
label var rr_hm_black "Recruiter Eval$\times$ Black Hiring Manager "
label var rr_hm_elite "Recruiter Eval$\times$ Elite School Hiring Manager "
label var rr_hm_empty "Recruiter Eval$\times$ Empty Hiring Manager "
label var p_passinterview "\Centerstack{P(Passes\! Interview)}"
label var p_acceptinterview "\Centerstack{P(Accepts\! Interview)}"
label var p_acceptoffer "\Centerstack{P(Accepts\! Offer)}"
label var recruiter_response "Recruiter Eval"

global myopts "bf(%15.2gc) sfmt(%15.2gc) prehead(\begin{tabular}{l*{14}{c}}) postfoot(\end{tabular}) se label noisily noeqlines varlabels(_cons Constant, end("" ) nolast)  starlevels(* 0.1 ** 0.05 *** 0.01) replace"
esttab one two three using ../Output/Tables/Appendix/TableC01.tex, $myopts keep(hm_female hm_black hm_elite hm_empty recruiter_response rr_*) stat(pvalue N r2, label("P(Recruiter Coeffs All Zero)" "\hline Observations" \(R^{2}\)) fmt(%9.2f 0 %9.2f))


